package cn.web03.websocket.service;

import cn.web03.websocket.dao.SocketUserRepository;
import cn.web03.websocket.po.SocketUser;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
/**
 * @author 零三 2020.06
 * https://web03.cn
 */
@Service
public class SocketUserServiceImpl implements SocketUserService {

    @Autowired
    SocketUserRepository repository;
    @Override
    public List<SocketUser> getSocketUsers() {
        List<SocketUser> all = repository.findAll();
        return all;
    }

    @Override
    public SocketUser saveSocketUsers(SocketUser socketUser) {
        return repository.saveAndFlush(socketUser);
    }

    @Override
    public SocketUser checkedSocketUser(SocketUser socketUser) {
        return repository.checkedSocketUser(socketUser.getUsername(),socketUser.getPassword());
    }

    @Override
    public SocketUser getSocketUser(Long id) {
        return repository.getOne(id);
    }

    @Override
    public List<SocketUser> getAllSocketUser() {
        return repository.findAll();
    }

}
